<form class="layui-form" action="">
    <input name="edId" id="edId1" type="hidden" />
    <input name="eConfigId" id="eConfigId1" type="hidden" />


    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">类型:</label>
            <div class="layui-input-inline">
                <select name="edbType" id="edbType1">
                    <option value="1" selected="selected">源数据库</option>
                    <option value="2">目标数据库</option>
                </select>
            </div>
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">IP+端口:</label>
            <div class="layui-input-inline">
                <input type="text" name="edbHost" id="edbHost1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户名:</label>
            <div class="layui-input-inline">
                <input type="text" name="edbUsername" id="edbUsername1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">密码:</label>
            <div class="layui-input-inline">
                <input type="text" name="edbPassword" id="edbPassword1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">数据库名:</label>
            <div class="layui-input-inline">
                <input type="text" name="eDataBase" id="eDataBase1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">数据库版本:</label>
            <div class="layui-input-inline">
                <input type="text" name="eMysqlType" id="eMysqlType1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">字符集:</label>
            <div class="layui-input-inline">
                <input type="text" name="eCharSet" id="eCharSet1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

</form>

<script type="text/javascript">

    $(function(){
        var data = $('#tempDbInfo').data('tempDbInfo');
        //console.log(data);
        if (data != null){
            document.getElementById("edId1").value= data.id;
            document.getElementById("eConfigId1").value= data.configId;
            // 下拉框类型
            $("#edbType1 option[value='" + data.dbType + "']").attr("selected", "selected");
            document.getElementById("edbHost1").value= data.dbHost;
            document.getElementById("edbUsername1").value= data.dbUsername;
            document.getElementById("edbPassword1").value= window.atob(data.dbPassword);
            document.getElementById("eDataBase1").value= data.dataBase;
            document.getElementById("eMysqlType1").value= data.mysqlType;
            document.getElementById("eCharSet1").value= data.charSet;

            $('#tempDbInfo').data('tempDbInfo',null);
        }else {
            document.getElementById("eConfigId1").value= $('#tempConfigId').attr('tempConfigId');
        }


        layui.use('form', function(){
            var form = layui.form;
            //form.render('radio');
            form.render('select');
        });
    })

</script>
